package C046;

import javax.swing.text.Keymap;
import java.util.HashMap;
import java.util.Scanner;

/**
 * ClassName: C02
 * Package: C046
 * Description:
 *
 * @Author BCXJ
 * @Create 2025/2/8 09:40
 * @Version 1.0
 * @Since 1.0
 */
public class C02 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int aim = scan.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scan.nextInt();
        }
        System.out.println(process(arr, aim));

    }

    private static int process(int[] arr, int aim) {
        int[] sum = sumProcess(arr);

        // 初始化最早出现的累加和的位置的统计
        HashMap<Integer, Integer> map = new HashMap<>();
        map.put(0, -1); // 0的前缀和最早出现在-1位置，可以自己去领悟一下为什么设置为-1
        int ans = 0;
        for (int i = 0; i < sum.length; i++) {
            if(!map.containsKey(sum[i])) {
                map.put(sum[i], i);
            }
            if(map.containsKey(sum[i] - aim)) {
                ans = Math.max(ans, i - map.get(sum[i] - aim));
            }
        }
        return ans;
    }

    private static int[] sumProcess(int[] arr) {
        int[] res = new int[arr.length];
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
            res[i] = sum;
        }
        return res;
    }
}
